<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="购车人名称">
              <j-input placeholder="请输入购车人名称" v-model="queryParam.orderNumber"></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="证件号码">
              <a-date-picker placeholder="请输入证件号码" v-model="queryParam.orderDate"></a-date-picker>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :md="6" :sm="8">
              <a-form-item label="客户地址">
                <j-input placeholder="请输入客户地址" v-model="queryParam.salesName"></j-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="识别代码(VIN)">
                <j-input placeholder="请输入识别代码(VIN)" v-model="queryParam.salesPhone"></j-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="购车方式">
                <j-input placeholder="请输入购车方式" v-model="queryParam.ownerName"></j-input>
              </a-form-item>
            </a-col>
             <a-col :md="6" :sm="8">
              <a-form-item label="购车时间">
                <j-input placeholder="请输入购车时间" v-model="queryParam.ownerName"></j-input>
              </a-form-item>
            </a-col>
          </template>
          <a-col :md="6" :sm="8">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button
                type="primary"
                @click="searchReset"
                icon="reload"
                style="margin-left: 8px"
              >重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">客户补填</a-button>
<!--      <a-button type="primary" icon="download" @click="handleExportXls('cxm-订单记录信息')">导出</a-button>-->
<!--      <a-upload-->
<!--        name="file"-->
<!--        :showUploadList="false"-->
<!--        :multiple="false"-->
<!--        :headers="tokenHeader"-->
<!--        :action="importExcelUrl"-->
<!--        @change="handleImportExcel"-->
<!--      >-->
<!--        <a-button type="primary" icon="import">导入</a-button>-->
<!--      </a-upload>-->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete" />删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px">
          批量操作
          <a-icon type="down" />
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        @change="handleTableChange"
      >
        <span slot="action" slot-scope="text, record">
          <a-button @click="showModal">作废</a-button>
          <a-modal v-model="visible2" title="作废提示" @ok="getInfo">
            <p>是否对该条记录进行作废？作废后将无法恢复！</p>
          </a-modal>
        </span>
        <span
          slot="filterDepositAttribute"
          slot-scope="depositAttribute"
        >{{ depositAttribute | filterDepositAttribute(depositAttribute) }}</span>
      </a-table>
    </div>
    <!-- table区域-end -->
    <!-- 表单区域 -->
    <!-- <cxmOrderManager-modal ref="modalForm" @ok="modalFormOk"></cxmOrderManager-modal> -->
    <buy-car-model ref="modalForm" @ok="modalFormOk"></buy-car-model>
    <cxm-order-manager-info-modal ref="cxmOrderManagerInfoModal"></cxm-order-manager-info-modal>
  </a-card>
</template>

<script>
import CxmOrderManagerModal from '../../cxm/modules/CxmOrderManagerModal.vue'
import CxmOrderManagerInfoModal from '../../cxm/modules/CxmOrderManagerInfoModal.vue'
import BuyCarModel from './BuyCarModel.vue'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JInput from '@/components/jeecg/JInput'
import moment from 'moment'
import { USER_INFO } from '@/store/mutation-types'
import Vue from 'vue'
import { getAction } from '@/api/manage'
export default {
  name: 'BuyCar',
  mixins: [JeecgListMixin],
  components: {
    CxmOrderManagerModal,
    CxmOrderManagerInfoModal,
    BuyCarModel,
    JInput,
    moment,
  },
  data() {
    return {
      description: 'cxm-订单管理页面',
      visible: false,
      visible2:false,
      // 表头
      loading:'',
      columns: [
        {
          title: '购车时间',
          align: 'center',
          dataIndex: 'fileNumber',
        },
        {
          title: '购车人名称',
          align: 'center',
          dataIndex: 'orderNumber',
        },
        {
          title: '购车人证件号码',
          align: 'center',
          dataIndex: 'ownerName',
        },
        {
          title: '客户手机号码',
          align: 'center',
          dataIndex: 'epositAmount',
        },
        {
          title: '购车方式',
          align: 'center',
          dataIndex: 'depositAttribute',
          scopedSlots: {
            customRender: 'filterDepositAttribute',
          },
        },
        {
          title: '车辆产品名称',
          align: 'center',
          dataIndex: 'epositAmount',
        },
        {
          title: '车辆中文品牌',
          align: 'center',
          dataIndex: 'epositAmount',
        },
        {
          title: '车辆公告型号',
          align: 'center',
          dataIndex: 'epositAmount',
        },
        {
          title: '车辆识别代码(VIN)',
          align: 'center',
          dataIndex: 'epositAmount',
        },
        {
          title: '发动机号码',
          align: 'center',
          dataIndex: 'epositAmount',
        },
        {
          title: '车辆销售价',
          align: 'center',
          dataIndex: 'epositAmount',
        },
        {
          title: '销售员',
          align: 'center',
          dataIndex: 'epositAmount',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: {
            customRender: 'action',
          },
        },
      ],

      url: {
        list: '/cxm/cxmOrderManager/list',
        delete: '/cxm/cxmOrderManager/delete',
        deleteBatch: '/cxm/cxmOrderManager/deleteBatch',
        exportXlsUrl: 'cxm/cxmOrderManager/exportXls',
        importExcelUrl: 'cxm/cxmOrderManager/importExcel',
      },
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${process.env.VUE_APP_BASE_API}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    showModal() {
      this.visible2 = true;
    },
    getInfo(record) {
      /* this.$refs.cxmOrderManagerInfoModal.showDrawer(record) */
      alert('服务器错误')
    },
  },
  filters: {
    filterTime(time) {
      return moment(time).format('YYYY-MM-DD')
    },
    filterDepositAttribute(depositAttribute) {
      switch (depositAttribute) {
        case "1":
          return "可退"
          break;
        case "2":
          return "不可退"
          break;
        case "3":
          return "有条件可退"
          break;
      }
    }
  },
}
</script>
<style scoped>
@import "~@assets/less/common.less";
</style>
